<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Tools extends CI_Controller {
	
	function index(){
		$account 		= $this->input->post('account');
		$times 			= $this->input->post('times');
		$times_type 	= $this->input->post('times_type');
		$repayment_type = $this->input->post('repayment_type');
		$apr 			= $this->input->post('apr');
		$reward 		= $this->input->post('reward');
		
		$vdata = array();
		if($account > 0){
			$idata['account'] 		= $account;
			$idata['apr'] 			= $apr;
			$idata['time_limit'] 	= $times;
			$idata['style'] 		= $repayment_type;
			if($times_type == 1){
				$idata['style'] 		= 0;
			}
	        $idata['is_day']		= $times_type;
	        $idata['time_limit_day']= $times;
	        $idata['reward']		= $reward;
	        $list = equal_interest($idata);
			$vdata['list'] 		= $list;
	        $idata['type']			= "all";
	        if($repayment_type == 3){
	        	$result 				= equal_month_interest($idata);
	        }else{
	        	$result 				= equal_month_interest_tools($idata);	
	        }
			
			$vdata['result'] 		= $result;
			
			$vdata['account'] 			= $account;
			$vdata['times'] 			= $times;
			$vdata['times_type'] 		= $times_type;
			$vdata['repayment_type'] 	= $repayment_type;
			if($times_type == 1){
				$vdata['repayment_type'] 	= 0;
			}
			
			$vdata['apr'] 				= $apr;
			$vdata['reward'] 			= $reward;
		}
		
		$vdata['title'] 		= '利息计算器 - '.CON_KEYWORDS;
		$this->load->view('site/tools', $vdata);
	}
	
	function downs(){
		$Shortcut = "[InternetShortcut]
		URL=".CON_WEBURL."/
		IDList=
		IconIndex=43
		IconFile=C:\Windows\system32\SHELL32.dll
		HotKey=1626
		[{000214A0-0000-0000-C000-000000000046}]
		Prop3=19,2";
		Header("Content-type: application/octet-stream");
		header("Content-Disposition: attachment; filename=".CON_PLATFORMNAME.".url;");
		echo $Shortcut;
	}
	
}